package com.shyb.lingxian.mine.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.shyb.lingxian.R;
import com.shyb.lingxian.Util.ToastUtil;
import com.shyb.lingxian.base.BaseActivity;
import com.shyb.lingxian.mine.presenter.AddressMangerActivityPresenter;
import com.shyb.lingxian.mine.view.AddressMangerView;

/**
 * Created by gs on 2018/3/26.
 */

public class AddressMangerActivity extends BaseActivity<AddressMangerActivityPresenter> implements AddressMangerView,View.OnClickListener {

    private RelativeLayout add_address;
    private RecyclerView addressManger_rv;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_address_manage);

        initHeadTitle("收货地址管理");

        intHeadRight("新增地址");

        findViews();
    }

    private void findViews() {

        ImageView headLeft = (ImageView) findViewById(R.id.iv_head_left);
        LinearLayout headRigh = (LinearLayout) findViewById(R.id.lin_head_right);
        add_address = (RelativeLayout) findViewById(R.id.add_address);


        addressManger_rv = (RecyclerView) findViewById(R.id.addressManger_rv);


        headLeft.setOnClickListener(this);
        headRigh.setOnClickListener(this);
        headRigh.setVisibility(View.VISIBLE);
        add_address.setOnClickListener(this);

    }

    @Override
    public void onError(String message) {
        ToastUtil.showToast(this,message);
    }

    @Override
    protected AddressMangerActivityPresenter initPresenter() {
        return new AddressMangerActivityPresenter(this);
    }

    @Override
    protected void initialize() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_head_left:
                onBackPressed();

                break;

            case R.id.lin_head_right:  //新增地址
                startActivity(new Intent(this,AddAdressActivity.class));

                break;

            case R.id.add_address:      //添加地址

                startActivity(new Intent(this,AddAdressActivity.class));
                break;
        }
    }
}
